<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>正方形</title>
</head>

<body>
  <h3>查看padding百分比计算规则</h3>
  <p>相对于父元素的宽度，这里body父元素去除默认的8像素margin后是379的宽，所以50%的padding就是179.5</p>
  <div class="jisuanbox">
    <div class="jisuan">
      
    </div>
  </div>
  <style>
    .jisuanbox{
      width: 300px;
      border: 1px solid #999;
    }
    .jisuan{
      padding: 10%;
      background: #a6b0e4;
    }
  </style>
  <div class="zfx">
    <div class="cont">
      <h2>
        hhah
      </h2>
      <p>
        内部文案
      </p>
    </div>
  </div>
  <p> </p>
  <style>
    .zfx {
      padding: 50%;
      background: #999;
      position: relative;
    }
    .cont {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      bottom: 0;
      padding-left: 20px;
      text-align: center;
    }
    .zfx2 {
      border: 1px solid rebeccapurple;
      font-size: 0;
      padding: 50%;
      background: #a6b0e4;
    }
  </style>
</body>

</html>